<!DOCTYPE html>
<html lang="cmn-Hans" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>邮件服务</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/frame/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/customer_admin.css}" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">邮件服务</div>
                <div class="layui-card-body">
                    <div class="layui-form" wid100>
                        <div class="layui-form-item">
                            <label class="layui-form-label">SMTP服务器</label>
                            <div class="layui-input-inline">
                                <input type="text" name="host" th:value="${current_email_info.host}" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">如：smtp.163.com</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">SMTP端口号</label>
                            <div class="layui-input-inline" style="width: 80px;">
                                <input type="text" name="port" lay-verify="number" th:value="${current_email_info.port}"
                                       class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">一般为 25 或 465</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">身份验证</label>
                            <div class="layui-input-block">
                                <input name="authenticate" title="开启" type="radio" th:checked="${current_email_info.authenticate} eq true"  th:value="true"/>
                                <div class="layui-unselect layui-form-radio layui-form-radioed">
                                    <i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                    <div>开启</div>
                                </div>
                                <input name="authenticate" title="关闭" type="radio" th:checked="${current_email_info.authenticate} eq false" th:value="false"/>
                                <div class="layui-unselect layui-form-radio">
                                    <i class="layui-anim layui-icon"></i>
                                    <div>关闭</div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">发件人邮箱</label>
                            <div class="layui-input-inline">
                                <input type="text" name="address" th:value="${current_email_info.address}"
                                       lay-verify="email"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">发件人昵称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" th:value="${current_email_info.username}"
                                       autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱登入密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" th:value="${current_email_info.password}"
                                       autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="set_system_email">确认保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/frame/layui/layui.js}"></script>
<script>
    layui.config({
        base: '/frame/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'form'], function () {
        var form = layui.form;
        var admin = layui.admin;
        form.on("submit(set_system_email)", function (t) {
            admin.req({
                url: '[[@{/admin/setEmail}]]'
                , type: 'post'
                , data: t.field
                , done: function (res) {
                    if (res.issuccess) {
                        layer.msg('更新成功！', {
                            //offset: '15px'
                            icon: 1
                            , time: 2000
                        });
                    } else {
                        layer.msg('更新失败，请检查输入是否有误！', {
                            //offset: '15px'
                            icon: 2
                            , time: 2000
                        });
                    }
                }
            });
        });
    });
</script>
</body>
</html>